﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Group/1/ManagePage.Master"
    Inherits="System.Web.Mvc.ViewPage<PagingDto>" %>

<asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
    <script type="text/javascript" src="/fckeditor/fckeditor.js"></script>
    <% Html.RenderAction("Top", "Group", new { code = ViewData["Code"] }); %>
    <% var pageNo = Convert.ToInt32(ViewData["PageNo"]); %>
    <% var topic = ViewData["Topic"] as GroupTopicDto ?? new GroupTopicDto(); %>
    <% var userDto = Session["User"] as UsersDto ?? new UsersDto(); %>
    <div class="main_wrapper clear">
        <div class="main">
            <div class="topic_view">
                <div class="topic_view_title">
                    <i class="icon"></i><span class="yahei">
                        <%= topic.GtTitle %></span>
                    <div class="reply">
                        <i class="icon"></i><a href="#">回应</a></div>
                </div>
                <% var i = 1; %>
                <% foreach (TopicDetailsDto detail in Model)
                   { %>
                <% detail.ChildDtos = detail.ChildDtos ?? new List<TopicDetailsDto>(); %>
                <div class="topic_view_item">
                    <div class="author">
                        <div class="face">
                            <img src="/Content/del/face100_01.jpg" width="80" height="80" alt="" /></div>
                        <div class="name">
                            <a href="#" target="_blank">
                                <%= detail.userDto.UserName %></a></div>
                        <div class="level">
                        </div>
                    </div>
                    <div class="article_wrap">
                        <div class="article">
                            <%= detail.TdContent %>
                        </div>
                        <div class="artcile_bar">
                            <%= pageNo == 0 ? i.ToString() : pageNo + "" + i %>楼<i class="pipe">|</i>
                            <%= detail.TdTime.ToString("MM月dd日 hh:mm") %><i class="pipe">|</i>
                            <% if (pageNo == 0 && i == 1)
                               { %>
                            <a href="#">回应</a>
                            <% }
                               else
                               { %>
                            <% if (detail.ChildDtos.Count == 0)
                               { %>
                            <a href="javascript:void(0);" onclick="ShowReply(<%= detail.TdId %>);">回复</a>
                            <% }
                               else
                               { %>
                            <a href="javascript:void(0);" onclick="ShowReply(<%= detail.TdId %>);">收起回复</a>
                            <% } %>
                            <% } %>
                        </div>
                        <% if (pageNo != 0 || i != 1)
                           { %>
                        <div class="comment_list" id="divReply<%= detail.TdId %>" style="<%= detail.ChildDtos.Count == 0 ? "display:none": "" %>">
                            <span class="icon arrow"></span>
                            <ul id="ulComment">
                                <% foreach (var child in detail.ChildDtos)
                                   { %>
                                <li>
                                    <div class="face">
                                        <img src="/Content/del/face50_01.jpg" width="30" height="30" alt="" /></div>
                                    <div class="say">
                                        <div class="name">
                                            <a href="#">
                                                <%= child.userDto.UserName %></a>
                                            <%= child.TdTime.ToString("MM月dd日 hh:mm")%></div>
                                        <div class="detail">
                                            <%= child.TdContent %></div>
                                    </div>
                                </li>
                                <% } %>
                            </ul>
                            <%= Html.Hidden("HidChildCount" + detail.TdId, detail.ChildDtos.Count) %>
                            <div class="add_comment_link">
                                <a href="javascript:void(0);" onclick="ShowComment(<%= detail.TdId %>);">我也说一句</a></div>
                        </div>
                        <% } %>
                    </div>
                </div>
                <% i++; %>
                <% } %>
                <div class="pages">
                    <% Html.RenderPartial("Paging"); %></div>
            </div>
            <% using (Html.BeginForm("Reply", "Topics"))
               { %>
            <div class="post_topic">
                <a name="post_new_topic"></a>
                <div class="title yahei">
                    <h2>
                        发表回应</h2>
                </div>
                <div class="post_topic_form reply_post_topic_form">
                    <div class="item editer_item">
                        <textarea name="Content" id="Content"></textarea>
                        <script type="text/javascript">
                            var fckContent = new FCKeditor('Content');
                            fckContent.Height = 230;
                            fckContent.Width = 575;
                            fckContent.ReplaceTextarea();
                        </script>
                    </div>
                    <div class="item btn_item">
                        <input name="" type="submit" value="提交回答" class="btn yahei" /></div>
                </div>
            </div>
            <%= Html.Hidden("topicId", topic.GtId) %>
            <%= Html.Hidden("CurrentDetailsId", 0) %>
            <% } %>
        </div>
        <div class="side">
            <div class="creat_link yahei">
                <a href="#post_new_topic">+创建新讨论</a></div>
            <ul class="my_topic">
                <li><a href="#">我发起的讨论</a></li>
                <li class="end"><a href="#">我回应的讨论</a></li>
            </ul>
            <div class="side_ad">
                <img src="/Content/del/side_ad1.jpg" alt="" /></div>
            <div class="hot_topic hot_ask">
                <div class="title yahei">
                    <h2>
                        精彩问答</h2>
                </div>
                <ul class="hot_topic_list">
                    <li><span class="num">130</span><a href="#">我比刘翔跑得快怎么办</a></li>
                    <li><span class="num">114</span><a href="#">急求李德印、应美凤等太极拳、剑带口令音</a></li>
                    <li><span class="num">103</span><a href="#">请教这辆山地车的前轮如何拆下来?</a></li>
                    <li><span class="num">96</span><a href="#">求一套时尚健身舞！！简单易学大方的</a></li>
                    <li><span class="num">80</span><a href="#">谁帮我介绍类似几个俯卧撑之类的单体运动方法</a></li>
                </ul>
            </div>
            <div class="hot_topic hot_subject">
                <div class="title yahei">
                    <h2>
                        热门话题</h2>
                </div>
                <ul class="hot_topic_list">
                    <li><span class="num">20</span><a href="#">魔声金涡轮、铜涡轮真假辨别要点！！！</a></li>
                    <li><span class="num">16</span><a href="#">有人知道视频-詹皇vs骑士30+5实录</a></li>
                    <li><span class="num">54</span><a href="#">金沙体育哪个信用最好?</a></li>
                    <li><span class="num">32</span><a href="#">能发我海绵宝宝滑冰之旅的地图嘛。</a></li>
                    <li><span class="num">87</span><a href="#">听说国踏的鞋子脚感不错，刚好想买鞋</a></li>
                </ul>
            </div>
        </div>
    </div>
    <script type="text/javascript">
        function ShowReply(id) {
            var oldDetailsId = $("#CurrentDetailsId").val();
            if ($("#divReply" + id).css("display") == "none") {
                ShowComment(id);
            }

            if ($("#HidChildCount" + oldDetailsId).val() == "0") {
                $("#divReply" + oldDetailsId).hide();
            }

            $("#divReply" + id).slideToggle("slow");
            $("#CurrentDetailsId").val(id);
        }

        function ShowComment(id) {
            $(".add_comment").remove();
            $("#divReply" + id).append("<div class=\"add_comment\"><div class=\"item\"><textarea id=\"replyContent\" cols=\"\" rows=\"\"></textarea></div><div class=\"item\"><input name=\"\" type=\"button\" value=\"发表\" class=\"btn\" onclick=\"SubmitChildReply();\" /></div></div>");
        }

        function SubmitChildReply() {
            var content = $("#replyContent").val();
            var topicId = $("#topicId").val();
            var detailsId = $("#CurrentDetailsId").val();
            $.ajax({
                type: "POST",
                url: '<%= Url.Action("ChildReply", "Topics") %>',
                data: "content=" + content + "&topicId=" + topicId + "&detailsId=" + detailsId,
                success: function (msg) {
                    if (msg == "success") {
                        var s = "<li><div class=\"face\"><img src=\"/Content/del/face50_01.jpg\" width=\"30\" height=\"30\" alt=\"\" /></div>";
                        s += "<div class=\"say\"><div class=\"name\"><a href=\"#\"><%= userDto.UserName %></a>";
                        s += '<%= DateTime.Now.ToString("MM月dd日 hh:mm")%>';
                        s += "</div><div class=\"detail\">" + content + "</div></div></li>";
                        $("#ulComment").append(s);
                        $(".add_comment").remove();
                    }
                }
            });
        }
    </script>
</asp:Content>
